(defun all-product (lst)
  (reduce #'* lst :initial-value 1)) 

(defun create-seq-arr (&rest dm)
  (let ((arr (make-array dm)))
    (dotimes (x (all-product dm))
      (setf (row-major-aref arr x) x))
    arr))

(defun find-ind (pos dlst)
  (if (null dlst)
      nil
      (let* ((x (all-product (cdr dlst)))
	     (i (floor (/ pos x)))
	     (m (mod pos x)))
	(cons i (find-ind m (cdr dlst))))))

(defun find-indices (arr position)
  (if (not (arrayp arr))
    (format t " Please give an array ")
    (let ((ardm (array-dimensions arr)))
      (format t "Array is of dimensions - ~A" ardm)
      (if (>= position (all-product ardm))
        (format t "Position ~A is not present in the array~%" position) 
	(find-ind position ardm)))))


